package com.example.demo.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.demo.controller.utils.R;
import com.example.demo.domain.consignee;
import com.example.demo.servise.impl.ibookserverimpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/books")
public class bookContoll2 {
    @Autowired
    private ibookserverimpl ibk;
    //    查全部
    @GetMapping
    public R getAll(){
        return new R(true,ibk.list());
    }
    //    保存
    @PostMapping
    public R save(@RequestBody consignee con ){
        return new R(ibk.save(con));
    }
    //    更新
    @PutMapping()
    public R update(@RequestBody consignee con ){
        return new R(ibk.updateById(con));
    }
    //    删除
    @DeleteMapping ("{id}")
    public R delete(@PathVariable Integer id ){
        return new R(ibk.removeById(id));
    }
    //    查单个
    @GetMapping("{id}")
    public R getById(@PathVariable Integer id){
        return new R(true,ibk.getById(id));
    }
    //    查询分页
    @GetMapping("{currentPage}/{pageSize}")
    public R getPage(@PathVariable int currentPage, @PathVariable int pageSize,consignee con){

        return new R(true,ibk.getPage(currentPage,pageSize,con));
    }
}
